package com.tangmu.rabbits.ui.activity.mine;


import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tangmu.rabbits.R;
import com.tangmu.rabbits.base.BaseActivity;
import com.tangmu.rabbits.constants.Constants;
import com.tangmu.rabbits.util.CommonUtil;
import com.tangmu.rabbits.widget.ThumbnailView;
import com.tangmu.rabbits.widget.popup.CommonPopupWindow;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 分享邀请
 */
public class InviteShareActivity extends BaseActivity implements CommonPopupWindow.ViewInterface {


    @BindView(R.id.iv_header_left)
    ThumbnailView ivHeaderLeft;
    @BindView(R.id.tv_header_title)
    TextView tvHeaderTitle;
    @BindView(R.id.iv_header_right)
    ThumbnailView ivHeaderRight;
    @BindView(R.id.tv_share_link)
    TextView tvShareLink;
    @BindView(R.id.tv_share_poster)
    TextView tvSharePoster;
    private CommonPopupWindow popupWindow;

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.statusBarColor(R.color.transparent).titleBar(R.id.headerView).init();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_invite_share;
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    protected void initView() {
        setHeaderImage(Constants.Position.LEFT, R.drawable.icon_back, false, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        setHeaderTitle("分享邀请");

    }

    @OnClick({R.id.tv_share_link, R.id.tv_share_poster})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_share_link:
                showSharePopup();
                break;
            case R.id.tv_share_poster:
                showSharePopup();
                break;
        }
    }

    /**
     * 我的分享
     */
    private void showSharePopup() {
        ///分享
        if (popupWindow != null && popupWindow.isShowing()) return;
        View upView = LayoutInflater.from(mContext).inflate(R.layout.popup_share_up, null);
        //测量View的宽高
        CommonUtil.measureWidthAndHeight(upView);
        popupWindow = new CommonPopupWindow.Builder(mContext)
                .setView(R.layout.popup_share_up)
                .setWidthAndHeight(ViewGroup.LayoutParams.MATCH_PARENT, upView.getMeasuredHeight())
                .setBackGroundLevel(0.5f)//取值范围0.0f-1.0f 值越小越暗
                .setAnimationStyle(R.style.AnimUp)
                .setViewOnclickListener(this)
                .create();
        popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
    }

    @Override
    public void getChildView(View view, int layoutResId) {

    }
}
